package com.syas.dao.daos;

import com.syas.base.dao.daos.EntityDao;
import com.syas.dao.interfaces.IFrmgerPfmceDao;
import com.syas.model.models.FrmgerPfmce;
import com.syas.service.models.FrmgerPfmceSearch;
import org.springframework.stereotype.Repository;

import java.math.BigInteger;
import java.util.List;

/**
 * Created by weigong on 2015/11/30.
 */
@Repository("FrmgerPfmceDao")
public class FrmgerPfmceDao extends EntityDao<Integer, FrmgerPfmce> implements IFrmgerPfmceDao {


    @Override
    public List<FrmgerPfmceSearch> listFrmgerPfmceSearchPageByHql(final String hql,final Integer page,final Integer pageSize) {
        return  this.getSession().createQuery(hql).setFirstResult(page*pageSize).setMaxResults(pageSize).list();
    }

    @Override
    public Long countFrmgerPfmceSearchPageByHql(final String countHql) {
        return  (Long)this.getSession().createQuery(countHql).uniqueResult();
    }

    @Override
    public List<FrmgerPfmceSearch> listFrmgerPfmceSearchPageBySql(String sql) {
        return (List<FrmgerPfmceSearch>)this.getSession().createSQLQuery(sql).list();
    }

    @Override
    public BigInteger countFrmgerPfmceSearchPageBySql(String countSql) {
        return (BigInteger)this.getSession().createSQLQuery(countSql).uniqueResult();
    }


    @Override
    public void deleteFrmgerPfmce() {
        String hql = " delete from FrmgerPfmce ";
        this.getSession().createQuery(hql).executeUpdate();
    }

    //根据e租宝账户名获取理财师业绩流水
    public List<FrmgerPfmce> pfmceWaterOfFmger(String ezboUname){
        String hql = "select new FrmgerPfmce(investamt,achieve,investtime,investpdt,redetime) from FrmgerPfmce frmgerPfmce where frmgerPfmce.financial_planner_cmer_ezbo=?";
        return (List<FrmgerPfmce>)this.getSession().createQuery(hql).setParameter(0, ezboUname).list();
    }

}
